<script src="/assets/js/jquery.bootbox.min.js"></script>
<script src="/b/<%=branch%>/proxy/config?key=item,unit,chip,egg,box,itemGroup,unitBase,igroup,gem,MsgList"></script>
<script src="/b/<%=branch%>/proxy/format?key=role,daily"></script>
<script src="/assets/item.js"></script>

<script>
    var pid = '<%=ret.pid%>',key = '<%=ret.key%>',config = <%-JSON.stringify(ret.config)%>;
</script>


<script>
    var dt_opts = {
        0:'不限制',
        1:'基础数据 [玩家等级，VIP等数据]',
        2:'成就数据 [玩家一些终身数据]',
        10:'日常数据 [玩家每日数据，只取当天数据]',
        100:'历史数据 [活动期间玩家日常数据总和]',
        101:'特殊逻辑[活动期间玩家最高值]',
        800:'特殊逻辑[FinishNum:已经完成条目]',
    }


    var defaultAfterShowForm = function(e,edit){
        if(!edit){
            $("#val").val(0);
            $("#max").val(1).attr("title","0:不限次数").tooltip({container:'body'});
        }
        //$("#sub").css({width:500});
        //$("#add").css({width:500});
    }

    var option = {
        pgbuttons:false,
        pginput:false,
        pgtext:"",
        recordtext:"",
        rowList:[],
        rowNum:10000,

        colModel : [
            {label: '奖励编号', name: 'ik',key:true,  width: 80,editable: true, hidden:false,fixed:true,
                editrules:{edithidden:true,required:true,integer:true,minValue:1,maxValue:99999999},
            },

            {label: '数据类型', name: 'dt', width: 80, editable: true,sortable:false, resize:false,search:false,fixed:true,
                formatter:'select', edittype:'select', editoptions:{ value:dt_opts },
            },
            {label: '数据来源', name: 'dk',width: 80, editable: true, sortable:false,resize:false,fixed:true,

            },

            {label: '比较方式', name: 'dc', width: 80, editable: true,resize:false,fixed:true,
                formatter:'select', edittype:'select', editoptions:{ value:{ 0:'大于等于',1:'小于等于'} },
            },

            {label: '任务目标', name: 'val',width: 80, editable: true, sortable:false,resize:false,fixed:true,
                editrules:{edithidden:true,required:true,integer:true}
            },

            {label: '限购数量', name: 'max',width: 80, editable: true, sortable:false,resize:false,fixed:true,
                editrules:{edithidden:true,required:true,integer:true}
            },

            {label: '扣除道具', name: 'sub', width: 250, editable: true,sortable:false, resize:false,search:false,fixed:true,
                formatter:cosjs.item.formatter,
                unformat:cosjs.item.unformat,
                editoptions: { dataInit: function (element) { new cosjs.item.select(element,1); } }
            },
            {label: '获得道具', name: 'add', width: 200, editable: true,sortable:false, resize:true,search:false,fixed:false,
                formatter:cosjs.item.formatter,
                unformat:cosjs.item.unformat,
                editoptions: { dataInit: function (element) { new cosjs.item.select(element); } }
            },

        ],

        afterShowAddForm : function(e){
            defaultAfterShowForm(e,0);
        },
        afterShowEditForm : function(e){
            defaultAfterShowForm(e,1);
        },

    }
    $(document).ready(function () {
        cosjs_create_jqgrid(option,{'pid':pid,'key':key});
    });
</script>

